package org.bl.chat.controller;


import io.swagger.annotations.ApiOperation;
import org.bl.chat.common.dto.Response;
import org.bl.chat.model.dto.ChannelSaveDTO;
import org.bl.chat.model.vo.ChannelVO;
import org.bl.chat.service.ChannelService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("channel")
public class ChannelController {

    @Resource
    private ChannelService channelService;
    @PostMapping("/save")
    @ApiOperation("新增频道")
    public Response save(@RequestBody @Valid ChannelSaveDTO request) {
        channelService.save(request);
        return Response.ok();
    }
    @GetMapping("/list")
    @ApiOperation("获取频道列表")
    public Response<List<ChannelVO>> list() {
        List<ChannelVO> channels = channelService.list();
        return Response.ok(channels);
    }

}
